/*
 * QSplitterAdapter.h  0.4.0 / Nov 29, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef QSPLITTERADAPTER_H
#define QSPLITTERADAPTER_H

#include "Cute4jSwing.h"

// QSplitterHandleAdapter Class. -----------------------------------------------

/*!
 * \brief QSplitterHandle Adapter.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT QSplitterHandleAdapter : public QSplitterHandle
{
public:
  QSplitterHandleAdapter(Qt::Orientation orientation, QSplitter *parent,
                         bool touchExpandable);
public:
  void setTouchExpandable(bool touchExpandable);
protected:
  virtual void resizeEvent(QResizeEvent *e);
  virtual void paintEvent(QPaintEvent *e);
  virtual void enterEvent(QEvent *e);
  virtual void leaveEvent(QEvent *e);
  virtual void mouseMoveEvent(QMouseEvent *e);
  virtual void mousePressEvent(QMouseEvent *e);
  virtual void mouseReleaseEvent(QMouseEvent *e);
private:
  void calculateArrows();
private:
  enum MousePosition { Outside, Over, OverFirst, OverSecond };
  MousePosition m_mousePosition;
  QPoint m_pressedPoint;
  QPoint m_firstArrow[3];
  QPoint m_secondArrow[3];
  QRect m_firstArrowRect;
  QRect m_secondArrowRect;
  bool m_touchExpandable;
};

// QSplitterAdapter Class. -----------------------------------------------------

/*!
 * \brief QSplitter Adapter.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class QSplitterAdapter : public QSplitter
{
public:
  QSplitterAdapter();
public:
  void setHandlePosition(int position);
  void setOneTouchExpandable(bool oneTouchExpandable);
  void setResizeWeight(double resizeWeight);
  void collapseFirst();
  void collapseSecond();
protected:
  QSplitterHandle *createHandle();
private:
  bool m_oneTouchExpandable;
  double m_resizeWeight;
};

#endif // QSPLITTERADAPTER_H
